package io.renren.api.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import io.renren.api.dao.BtCategroyManageDao;
import io.renren.api.entity.BtCategroyManageEntity;
import io.renren.api.entity.BtCustomerBaseEntity;
import io.renren.api.entity.BtCustomerProBaseinfoEntity;
import io.renren.api.service.BtCategroyManageService;
import io.renren.api.service.BtCustomerBaseService;
import io.renren.api.service.BtCustomerProBaseinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("btCategroyManageService")
public class BtCategroyManageServiceImpl extends ServiceImpl<BtCategroyManageDao, BtCategroyManageEntity> implements BtCategroyManageService {

    @Override
    public List<BtCategroyManageEntity> queryList(Map<String, Object> params){
        List<BtCategroyManageEntity> deptList =
                this.selectList(new EntityWrapper<BtCategroyManageEntity>());

        for(BtCategroyManageEntity sysDeptEntity : deptList){
            BtCategroyManageEntity parentDeptEntity =  this.selectById(sysDeptEntity.getPid());
            if(parentDeptEntity != null){
                sysDeptEntity.setParentName(parentDeptEntity.getName());
            }
        }
        return deptList;
    }
    @Override
    public List<Long> queryCateMagIdList(Long pid){
        return baseMapper.queryCateMagIdList(pid);
    }
    /**
     *Catatype:1国内2国际3节日4亲子
     */

    @Override
    public List<Map<String,Object>> getFirstfenleicatag(){
        //主分类
        Map<String,Object> backdata= new HashMap<>();
        List<Map<String,Object>>content=new ArrayList<>();
        Map<String,Object>subcontent = null;
        List<BtCategroyManageEntity> yjfllist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("deepnum",1));
        BtCategroyManageEntity forone =null;

        if(yjfllist.size()<=0){
            return null;
        }
        //1左边国内分类
        for(BtCategroyManageEntity  tb:yjfllist){
            if(tb.getCatatype().equals("1")){
                forone=tb;
                break;
            }
        }
        subcontent = new HashMap<>();
        subcontent.put("cataname",forone.getName());
        //2获取国内主题分类 写死的国内主题分类类别为：1,1
        BtCategroyManageEntity zhuti = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","1,1"));
        //3国内主题分类
        List<BtCategroyManageEntity> zhutizhifen = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",zhuti.getId()));
        List<Map<String ,Object>> leftcontent =  new ArrayList<>();
        List<Map<String ,Object>>rightcontentlist= new ArrayList<>();
        Map<String ,Object> lzsub = null;
        Map<String ,Object> rzsub = null;
        leftcontent =  new ArrayList<>();
        rightcontentlist= new ArrayList<>();
        for(BtCategroyManageEntity ztfe:zhutizhifen){

            List<BtCategroyManageEntity> tempztf = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                                                      .eq("pid",ztfe.getId()));

            int sum=0;
            List<Map<String ,Object>>ttleftcontentlist =  new ArrayList<>();
            for(BtCategroyManageEntity btcd :tempztf){
                lzsub = new HashMap<>();
                rzsub = new HashMap<>();
                lzsub.put("name",btcd.getName());
                lzsub.put("linkid",btcd.getId());
                lzsub.put("link","link?cata=1&zt="+btcd.getId());
                ttleftcontentlist.add(lzsub);
                if(sum<2){
                    if(tempztf.get(sum)!=null){
                        rzsub.put("name",btcd.getName());
                        rzsub.put("linkid",btcd.getId());
                        rzsub.put("link","link?cata=1&zt="+btcd.getId());
                        rightcontentlist.add(rzsub);
                    }
                    sum++;
                }
            }

            Map<String, Object>tec = new HashMap<>();
            tec.put("subcataname",ztfe.getName());
            tec.put("subcataval",ttleftcontentlist);

            leftcontent.add(tec);
        }
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);


        //1左边国机分类
        subcontent = new HashMap<>();
        for(BtCategroyManageEntity  tb:yjfllist){
            if(tb.getCatatype().equals("2")){
                forone=tb;
                break;
            }
        }
        leftcontent =  new ArrayList<>();
        rightcontentlist= new ArrayList<>();
        //2获取国际主题分类 ：2,1
        List<Map<String ,Object>> bgjztlist =  new ArrayList<>();
        BtCategroyManageEntity gjzt = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","2,1"));
        List<BtCategroyManageEntity>gjztlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",gjzt.getId()));
        for(BtCategroyManageEntity gjztsub:gjztlist){
            lzsub = new HashMap<>();
            lzsub.put("name",gjztsub.getName());
            lzsub.put("linkid",gjztsub.getId());
            lzsub.put("link","link?cata=2&zt="+gjztsub.getId());
            bgjztlist.add(lzsub);
        }
        Map<String, Object>tec = new HashMap<>();
        tec.put("subcataname","国际主题");
        tec.put("subcataval",bgjztlist);
        leftcontent.add(tec);
        //2获取游学国家分类 写死的国内主题分类类别为：2,5
        List<Map<String ,Object>> bgjyxgjlist =  new ArrayList<>();
        BtCategroyManageEntity yxgj = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","2,5"));
        List<BtCategroyManageEntity>gjyxgjlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",yxgj.getId()));
        for(BtCategroyManageEntity yxgjsub:gjyxgjlist){
            lzsub = new HashMap<>();
            lzsub.put("name",yxgjsub.getName());
            lzsub.put("linkid",yxgjsub.getId());
            lzsub.put("link","link?cata=2&yxgj="+yxgjsub.getId());
            bgjyxgjlist.add(lzsub);
            rightcontentlist.add(lzsub);
        }
        tec = new HashMap<>();
        tec.put("subcataname","游学国家");
        tec.put("subcataval",bgjyxgjlist);
        leftcontent.add(tec);
        //3获取游学国家分类 写死的国内主题分类类别为：2,5
        List<Map<String ,Object>> bgjcfcslist =  new ArrayList<>();
        BtCategroyManageEntity cfcs = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","2,2"));
        List<BtCategroyManageEntity>gjcfcslist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",cfcs.getId()));
        for(BtCategroyManageEntity cfgcs:gjcfcslist){
            lzsub = new HashMap<>();
            lzsub.put("name",cfgcs.getName());
            lzsub.put("linkid",cfgcs.getId());
            lzsub.put("link","link?cata=2&zbcs="+cfgcs.getId());
            bgjcfcslist.add(lzsub);
        }
        tec = new HashMap<>();
        tec.put("subcataname","出发城市");
        tec.put("subcataval",bgjcfcslist);
        leftcontent.add(tec);
        subcontent.put("cataname",forone.getName());
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);
        //获取假日活动分类
        //1左边分类
        subcontent = new HashMap<>();
        for(BtCategroyManageEntity  tb:yjfllist){
            if(tb.getCatatype().equals("3")){
                forone=tb;
                break;
            }
        }
        leftcontent =  new ArrayList<>();
        rightcontentlist= new ArrayList<>();
        //2获取周末活动主题分类 类别为：3,2
        List<Map<String ,Object>> bzmhdztlist =  new ArrayList<>();
        BtCategroyManageEntity zmhdzt = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","3,2"));
        List<BtCategroyManageEntity>zmhdztlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",zmhdzt.getId()));
        for(BtCategroyManageEntity yxgjsub:zmhdztlist){
            lzsub = new HashMap<>();
            lzsub.put("name",yxgjsub.getName());
            lzsub.put("linkid",yxgjsub.getId());
            lzsub.put("link","link?cata=3&zbcs="+yxgjsub.getId());
            bzmhdztlist.add(lzsub);
            rightcontentlist.add(lzsub);
        }
        tec = new HashMap<>();
        tec.put("subcataname",zmhdzt.getName());
        tec.put("subcataval",bzmhdztlist);
        leftcontent.add(tec);
        //2获取周末活动活动城市分类 类别为：3,1
        List<Map<String ,Object>> bzmhdhdddlist =  new ArrayList<>();
        BtCategroyManageEntity zmhdhddd = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","3,1"));
        List<BtCategroyManageEntity>zmhdhdddlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",zmhdhddd.getId()));
        for(BtCategroyManageEntity yxgjsub:zmhdhdddlist){
            lzsub = new HashMap<>();
            lzsub.put("name",yxgjsub.getName());
            lzsub.put("linkid",yxgjsub.getId());
            lzsub.put("link","link?cata=3&zt="+yxgjsub.getId());
            bzmhdhdddlist.add(lzsub);
        }
        tec = new HashMap<>();
        tec.put("subcataname",zmhdhddd.getName());
        tec.put("subcataval",bzmhdhdddlist);
        leftcontent.add(tec);

        //3获取周末活动招生对象分类 类别为：3,3
        List<Map<String ,Object>> bzmhdzsdxlist =  new ArrayList<>();
        BtCategroyManageEntity zmhdzsdx= this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","3,3"));
        List<BtCategroyManageEntity>zmhdzsdxlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",zmhdzsdx.getId()));
        for(BtCategroyManageEntity yxgjsub:zmhdzsdxlist){
            lzsub = new HashMap<>();
            lzsub.put("name",yxgjsub.getName());
            lzsub.put("linkid",yxgjsub.getId());
            lzsub.put("link","link?cata=3&zsdx="+yxgjsub.getId());
            bzmhdzsdxlist.add(lzsub);
        }
        tec = new HashMap<>();
        tec.put("subcataname",zmhdzsdx.getName());
        tec.put("subcataval",bzmhdzsdxlist);
        leftcontent.add(tec);
        subcontent.put("cataname",forone.getName());
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);

        content.add(subcontent);

        //活动城市分类
        for(BtCategroyManageEntity  tb:yjfllist){
            if(tb.getCatatype().equals("1")){
                forone=tb;
                break;
            }
        }
        subcontent = new HashMap<>();
        subcontent.put("cataname","活动城市");
        leftcontent =  new ArrayList<>();
        rightcontentlist= new ArrayList<>();
        List<Map<String ,Object>> bzbcslist =  new ArrayList<>();
        BtCategroyManageEntity zbcs = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","1,2"));
        List<BtCategroyManageEntity>zbcsfenleilist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",zbcs.getId()));
        lzsub =new HashMap<>();
        rzsub = new HashMap<>();;
        for(BtCategroyManageEntity ztfe:zbcsfenleilist){

            List<BtCategroyManageEntity> tempztf = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                    .eq("pid",ztfe.getId()));

            int sum=0;
            List<Map<String ,Object>>ttleftcontentlist =  new ArrayList<>();
            for(BtCategroyManageEntity btcd :tempztf){
                lzsub = new HashMap<>();
                rzsub = new HashMap<>();
                lzsub.put("name",btcd.getName());
                lzsub.put("linkid",btcd.getId());
                lzsub.put("link","link?cata=1&zbcs="+btcd.getId());
                ttleftcontentlist.add(lzsub);
                if(sum<2){
                    if(tempztf.get(sum)!=null){
                        rzsub.put("name",btcd.getName());
                        rzsub.put("linkid",btcd.getId());
                        rzsub.put("link","link?cata=1&zbcs="+btcd.getId());
                        rightcontentlist.add(rzsub);
                    }
                    sum++;
                }
            }

            tec = new HashMap<>();
            tec.put("subcataname",ztfe.getName());
            tec.put("subcataval",ttleftcontentlist);

            leftcontent.add(tec);
        }
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);

        return content;
    }
    @Autowired
    private BtCustomerProBaseinfoService btCustomerProBaseinfoService;
    @Autowired
    private BtCustomerBaseService btCustomerBaseService;
    /**
     *获取首页国际分类
     */
    @Override
    public List<Map<String,Object>> getFirstGuoJiYingcatag(){
        //主分类
        Map<String,Object> backdata= new HashMap<>();
        List<Map<String,Object>>content=new ArrayList<>();
        Map<String,Object>subcontent = null;
        List<BtCategroyManageEntity> guojifenlei = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("catatype",2));
        BtCategroyManageEntity forone =null;
        BtCategroyManageEntity tempbean =null;
        Map<String ,Object> lzsub = null;
        Map<String ,Object> rzsub = null;
        if(guojifenlei.size()<=0){
            return null;
        }
        //1左边分类游学国家
        for(BtCategroyManageEntity  tb:guojifenlei){
            if(tb.getCatatype().equals("2,5")){
                forone=tb;
                break;
            }
        }
        subcontent = new HashMap<>();
        subcontent.put("cataname",forone.getName());
        List<BtCategroyManageEntity> yxgjsub = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",forone.getId()));
        List<Map<String ,Object>>rightcontentlist= new ArrayList<>();
        List<Map<String ,Object>> leftcontent =  new ArrayList<>();
        //1.1游学国家分类
        for(BtCategroyManageEntity tb :yxgjsub){
            rzsub = new HashMap<>();
            rzsub.put("id",tb.getId());
            rzsub.put("name",tb.getName());
            rzsub.put("linkid","link?cata=2&yxgj="+tb.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        //1.2游学国家分类 右边分类
         tempbean = this.selectOne(new EntityWrapper<BtCategroyManageEntity>().eq("catatype","2,1"));
         List<BtCategroyManageEntity> yxgjztlist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",tempbean.getId()));
         for(Map<String ,Object> tb :rightcontentlist){
             List<Map<String ,Object>>ttleftcontentlist =  new ArrayList<>();
             for(BtCategroyManageEntity btcd :yxgjztlist){
                 lzsub = new HashMap<>();
                 lzsub.put("id",btcd.getId());
                 lzsub.put("name",btcd.getName());
                 lzsub.put("linkid","link?cata=2&yxgj="+tb.get("id")+"&zt="+btcd.getId());
                 ttleftcontentlist.add(lzsub);
             }

             Map<String, Object>tec = new HashMap<>();
             tec.put("subcataname",tb.get("name")+"营");
             tec.put("subcataval",ttleftcontentlist);

             leftcontent.add(tec);
         }
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);

        //1左边分类游戏主题
        for(BtCategroyManageEntity  tb:guojifenlei){
            if(tb.getCatatype().equals("2,1")){
                forone=tb;
                break;
            }
        }
        subcontent = new HashMap<>();
        subcontent.put("cataname",forone.getName());
        yxgjsub = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",forone.getId()));
        rightcontentlist= new ArrayList<>();
        leftcontent =  new ArrayList<>();
        //1.1游学主题
        for(BtCategroyManageEntity tb :yxgjsub){
            rzsub = new HashMap<>();
            rzsub.put("id",tb.getId());
            rzsub.put("name",tb.getName());
            rzsub.put("linkid","link?cata=2&zt="+tb.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        //1.2游学国家分类 右边分类
        tempbean = this.selectOne(new EntityWrapper<BtCategroyManageEntity>().eq("catatype","2,5"));
        List<BtCategroyManageEntity> yxgjguojialist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",tempbean.getId()));
        for(Map<String ,Object> tb :rightcontentlist){
            List<Map<String ,Object>>ttleftcontentlist =  new ArrayList<>();
            for(BtCategroyManageEntity btcd :yxgjguojialist){
                lzsub = new HashMap<>();

                lzsub.put("id",btcd.getId());
                lzsub.put("name",btcd.getName());
                lzsub.put("linkid","link?cata=2&zt="+tb.get("id")+"&yxgj="+btcd.getId());
                ttleftcontentlist.add(lzsub);
            }

            Map<String, Object>tec = new HashMap<>();
            tec.put("subcataname",tb.get("name"));
            tec.put("subcataval",ttleftcontentlist);

            leftcontent.add(tec);
        }
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);

        //1左边主办城市主题
        for(BtCategroyManageEntity  tb:guojifenlei){
            if(tb.getCatatype().equals("2,2")){
                forone=tb;
                break;
            }
        }
        subcontent = new HashMap<>();
        subcontent.put("cataname",forone.getName());
        yxgjsub = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",forone.getId()));
        rightcontentlist= new ArrayList<>();
        leftcontent =  new ArrayList<>();
        //1.1主办城市
        for(BtCategroyManageEntity tb :yxgjsub){
            rzsub = new HashMap<>();
            rzsub.put("id",tb.getId());
            rzsub.put("name",tb.getName());
            rzsub.put("linkid","link?cata=2&zbcs="+tb.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        //1.2主办城市 右边分类
        //1.2.1出发城市
        List<Map<String ,Object>>ttleftcontentlist =  new ArrayList<>();
        for(BtCategroyManageEntity tb :yxgjsub){
            lzsub = new HashMap<>();
            lzsub.put("id",tb.getId());
            lzsub.put("name",tb.getName());
            lzsub.put("linkid","link?cata=2&zbcs="+tb.getId());
            ttleftcontentlist.add(lzsub);
        }
        Map<String, Object>tec = new HashMap<>();
        tec.put("subcataname","出发城市");
        tec.put("subcataval",ttleftcontentlist);
        leftcontent.add(tec);
        //1.2.1美国
        tec = new HashMap<>();
        tec.put("subcataname","去美国机构");
        tec.put("subcataval",getleftyouxejigou("108"));
        leftcontent.add(tec);
        //1.2.1英国
        tec = new HashMap<>();
        tec.put("subcataname","去英国机构");
        tec.put("subcataval",getleftyouxejigou("109"));
        leftcontent.add(tec);
        //1.2.1加拿大
        tec = new HashMap<>();
        tec.put("subcataname","去加拿大机构");
        tec.put("subcataval",getleftyouxejigou("110"));
        leftcontent.add(tec);
        //1.2.1澳洲
        tec = new HashMap<>();
        tec.put("subcataname","去澳洲机构");
        tec.put("subcataval",getleftyouxejigou("111"));
        leftcontent.add(tec);
        //1.2.1欧洲
        tec = new HashMap<>();
        tec.put("subcataname","去欧洲机构");
        tec.put("subcataval",getleftyouxejigou("112"));
        leftcontent.add(tec);
        //1.2.1俄罗斯
        tec = new HashMap<>();
        tec.put("subcataname","去俄罗斯机构");
        tec.put("subcataval",getleftyouxejigou("113"));
        leftcontent.add(tec);
        subcontent.put("rightcontent",rightcontentlist);
        subcontent.put("lelftcontent",leftcontent);
        content.add(subcontent);

        return content;
    }
    private List<Map<String ,Object>> getleftyouxejigou(String cid){
        List<Map<String ,Object>> ttleftcontentlist =  new ArrayList<>();
        List<BtCustomerProBaseinfoEntity> cbeanlist = btCustomerProBaseinfoService.selectList(new EntityWrapper<BtCustomerProBaseinfoEntity>().like("cfcs_ids",cid));
        List<Long> inarr = new ArrayList<>();

        for(BtCustomerProBaseinfoEntity tb :cbeanlist){
            if(inarr.indexOf(tb.getCustId())>0) continue;
            inarr.add(tb.getCustId());
            BtCustomerBaseEntity cbbean = btCustomerBaseService.selectById(tb.getCustId());
            Map<String ,Object> lzsub = new HashMap<>();
            lzsub.put("id",cbbean.getId());
            lzsub.put("name",cbbean.getName());
            lzsub.put("linkid","/dianpu/"+cbbean.getId());
            ttleftcontentlist.add(lzsub);
        }
        return ttleftcontentlist;
    }

    /**
     * 周末
     */
    public List<Map<String,Object>> getFirstZhouMocatag(){

        List<Map<String,Object>>content=new ArrayList<>();
        Map<String,Object>subcontent = null;

        BtCategroyManageEntity forone = this.selectOne(new EntityWrapper<BtCategroyManageEntity>().eq("catatype","3"));
        //2获取周末主题分类
        subcontent = new HashMap<>();
        BtCategroyManageEntity zhuti = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","3,2"));
        subcontent.put("cataname",zhuti.getName());
        List<BtCategroyManageEntity> zhutizhifen = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",zhuti.getId()));

        List<Map<String ,Object>>rightcontentlist= new ArrayList<>();

        Map<String ,Object> rzsub = null;

        rightcontentlist= new ArrayList<>();
        for(BtCategroyManageEntity ztfe:zhutizhifen) {
            rzsub = new HashMap<>();
            rzsub.put("name", ztfe.getName());
            rzsub.put("linkid", ztfe.getId());
            rzsub.put("link", "link?cata=3&zt=" + ztfe.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        content.add(subcontent);



        //2获取主办城市分类
        subcontent = new HashMap<>();
        BtCategroyManageEntity zbcs = this.selectOne(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",forone.getId()).eq("catatype","3,1"));
        subcontent.put("cataname",zbcs.getName());
        List<BtCategroyManageEntity> zbcsfen = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",zbcs.getId()));
        rightcontentlist= new ArrayList<>();
        for(BtCategroyManageEntity ztfe:zbcsfen) {
            rzsub = new HashMap<>();
            rzsub.put("name", ztfe.getName());
            rzsub.put("linkid", ztfe.getId());
            rzsub.put("link", "link?cata=3&zbcs=" + ztfe.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        content.add(subcontent);

        //3获取周末活动招生对象
        subcontent = new HashMap<>();
        BtCategroyManageEntity zsdx = this.selectOne(new EntityWrapper<BtCategroyManageEntity>().eq("pid",forone.getId()).eq("catatype","3,3"));
        subcontent.put("cataname",zsdx.getName());
        List<BtCategroyManageEntity> zsdxfen = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",zsdx.getId()));
        rightcontentlist= new ArrayList<>();
        for(BtCategroyManageEntity ztfe:zsdxfen) {
            rzsub = new HashMap<>();
            rzsub.put("name", ztfe.getName());
            rzsub.put("linkid", ztfe.getId());
            rzsub.put("link","link?cata=3&zsdx=" + ztfe.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        content.add(subcontent);

        //3获取周末活动营期
        subcontent = new HashMap<>();
        BtCategroyManageEntity yingqi = this.selectOne(new EntityWrapper<BtCategroyManageEntity>().eq("pid",forone.getId()).eq("catatype","3,3"));
        subcontent.put("cataname",yingqi.getName());
        List<BtCategroyManageEntity> yingqifen = this.selectList(new EntityWrapper<BtCategroyManageEntity>()
                .eq("pid",yingqi.getId()));
        rightcontentlist= new ArrayList<>();
        for(BtCategroyManageEntity ztfe:yingqifen) {
            rzsub = new HashMap<>();
            rzsub.put("name", ztfe.getName());
            rzsub.put("linkid", ztfe.getId());
            rzsub.put("link", "link?cata=3&yq=" + ztfe.getId());
            rightcontentlist.add(rzsub);
        }
        subcontent.put("rightcontent",rightcontentlist);
        content.add(subcontent);
        return content;
    }

    /**
     * 列表分类
     */
   public List<Map<String,Object>> getListAllCatagroy(){
        List<Map<String,Object>>content=new ArrayList<>();
        List<BtCategroyManageEntity> yjfllist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",0L));
        Map<String,Object> zufenlei=null;
        List<Map<String,Object>>erjifenlei=null;
       List<Map<String,Object>>sanjifenlei=null;
       Map<String,Object> sanjimap = null;
        for(BtCategroyManageEntity zfl:yjfllist){
            zufenlei=new HashMap<>();
            zufenlei.put("skey","cata");
            zufenlei.put("sval",zfl.getCatatype());
            zufenlei.put("title",zfl.getName());
            //获取二级分类
            List<BtCategroyManageEntity> erjilist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",zfl.getId()));
            String erjsearchkey ="";
            erjifenlei = new ArrayList<>();
            for(BtCategroyManageEntity erji:erjilist){
                String[] erjiz = erji.getCatatype().split(",");
                switch(erjiz[1]){
                    case "1":
                        erjsearchkey="zt";
                        break;
                    case "2":
                        erjsearchkey="zbcs";
                        break;
                    case "3":
                        erjsearchkey="zsdx";
                        break;
                    case "4":
                        erjsearchkey="yq";
                        break;
                    case "5":
                        erjsearchkey="yxgj";
                        break;
                }
                Map<String,Object> erjiemap = new HashMap<>();
                erjiemap.put("title",erji.getName());
                //获取3级分类
                List<BtCategroyManageEntity> sanjilist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",erji.getId()));
                sanjifenlei= new ArrayList<>();
                for(BtCategroyManageEntity sanji :sanjilist){

                    List<BtCategroyManageEntity> sijilist = this.selectList(new EntityWrapper<BtCategroyManageEntity>().eq("pid",sanji.getId()));
                    if(sijilist.size()>0){//有四级分类
                        for(BtCategroyManageEntity siji :sijilist){
                            sanjimap = new HashMap<>();
                            sanjimap.put("skey",erjsearchkey);
                            sanjimap.put("sval",siji.getId());
                            sanjimap.put("title",siji.getName());
                            sanjifenlei.add(sanjimap);
                        }

                    }else{
                        sanjimap = new HashMap<>();
                        sanjimap.put("skey",erjsearchkey);
                        sanjimap.put("sval",sanji.getId());
                        sanjimap.put("title",sanji.getName());
                        sanjifenlei.add(sanjimap);
                    }
                }
                erjiemap.put("vallist",sanjifenlei);

                erjifenlei.add(erjiemap);
            }
            zufenlei.put("vallist",erjifenlei);
            content.add(zufenlei);
        }
        return content;
    }
}
